Skip to main content
Write a program to print prime numbers from 1 to 50 in C++ Language - Program to print prime numbers from 1 to 50 in C++
Program to print prime numbers from 1 to 50 in C++ Language
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
cout << endl << "Prime Numbers between 1 and 50 are:\n";
for(int i=2;i<=50;++i)
{
int c=0;
for(int j=2;j<=sqrt(i);++j)
{
if(i%j==0)
c=1;
}
if(c==0)
cout << endl <<i<<" ";
}
cout << endl;
return 0;
}
इस कोड को हमने CODEBLOCK पर बना कर run किया है
Comments
Post a Comment